import { Injectable } from '@angular/core';
import { NzModalRef, NzModalService } from 'ng-zorro-antd/modal';
import { UniqueCodeSettingComponent } from './unique-code-setting.component';
import { LocalizationService } from '@abp/ng.core';

export interface UniqueCodeSettingOptions {
  width?: number;
}

@Injectable({
  providedIn: 'root'
})
export class UniqueCodeSettingService {
  constructor(
    private modalService: NzModalService,
    private localizationService: LocalizationService
  ) {}

  show(settingKey: string, options?: UniqueCodeSettingOptions): NzModalRef {
    return this.modalService.create({
      nzTitle: this.l('BasicArchives::UI:UniqueCodeSetting.Title'),
      nzContent: UniqueCodeSettingComponent,
      nzWidth: options?.width || 800,
      nzFooter: null,
      nzClosable: true,
      nzMaskClosable: false,
      nzComponentParams: {
        settingKey: settingKey
      }
    });
  }

  protected l(key: string, ...args: any[]): string {
    return this.localizationService.instant(key, ...args);
  }
} 